//
//  VisitorLoginView.swift
//  SineWeibo
//
//  Created by keshuaiguo on 16/1/14.
//  Copyright © 2016年 keshuaiguo. All rights reserved.
//

import UIKit
import SnapKit

class VisitorLoginView: UIView {
    
    
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        setUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setUI() {
        
        addSubview(circleIcon)
        addSubview(largeHouse)
        addSubview(tipLable)
        addSubview(loginBtn)
        addSubview(registerBtn)
        
        //圈圈添加约束
        circleIcon.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(self.snp_centerX)
            make.centerY.equalTo(self.snp_centerY).offset(-60)
        }
        //大房子添加约束
        largeHouse.snp_makeConstraints { (make) -> Void in
            make.center.equalTo(circleIcon.snp_center)
        }
        //提示框约束
        tipLable.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(circleIcon.snp_centerX)
            make.top.equalTo(circleIcon.snp_bottom).offset(15)
            make.width.equalTo(225)
        }
        //登录按钮约束
        loginBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(tipLable.snp_bottom).offset(15)
            make.left.equalTo(tipLable.snp_left)
            make.width.equalTo(100)
        }
        //注册按钮
        registerBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(tipLable.snp_bottom).offset(15)
            make.right.equalTo(tipLable.snp_right)
            make.width.equalTo(100)
            
        }
        
    }
    
    //懒加载所有的子视图
    //圈圈
    lazy var circleIcon: UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_smallicon"))
    //大房子
    lazy var largeHouse: UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_house"))
    
    //提示
    lazy var tipLable: UILabel = {
        
        let l = UILabel()
        l.font = UIFont.systemFontOfSize(15)
        l.text = "登陆后别人就可以访问和评论你的微博,你也可以认识更多的好朋友!!"
        l.textColor = UIColor.darkGrayColor()
        l.textAlignment = .Center
        l.numberOfLines = 0
        
        //设置大小
        l.sizeToFit()
        return l
    }()
    //登录按钮
    lazy var loginBtn: UIButton = {
    
        let btn = UIButton()
        btn.setTitle("登录", forState: .Normal)
        btn.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(17)
        
        let img = UIImage(named: "common_button_white_disable")!
        let w = Int(img.size.width * 0.5)
        let h = Int(img.size.height * 0.5)
        btn.setBackgroundImage(img.stretchableImageWithLeftCapWidth(w, topCapHeight: h), forState: .Normal)
        return btn
    }()
    //注册按钮
    lazy var registerBtn: UIButton = {
        
        let btn = UIButton()
        btn.setTitle("登录", forState: .Normal)
        btn.setTitleColor(UIColor.orangeColor(), forState: .Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(17)
        
        let img = UIImage(named: "common_button_white_disable")!
        let w = Int(img.size.width * 0.5)
        let h = Int(img.size.height * 0.5)
        btn.setBackgroundImage(img.stretchableImageWithLeftCapWidth(w, topCapHeight: h), forState: .Normal)
        return btn
    }()

    
}

